@layout("/common/_container.html"){
<div class="ibox float-e-margins slim-margin">
    <div class="ibox-content">
        <div class="form-horizontal" id="data-input">

            <div class="row">
                <div class="col-sm-6 b-r">
                	<div class="form-group">
	                	<label class="col-sm-3 control-label">车牌号</label>
	                	<div class="col-sm-9">
	                		<input id="carNum" class="form-control" name="carNum" v-model="item.carNum" minlength="1" required/>
	                	</div>
                	</div>                	
                	<div class="form-group">
	                	<label class="col-sm-3 control-label">车主姓名</label>
	                	<div class="col-sm-9">
	                		<input id="owner" class="form-control" name="owner" v-model="item.owner" minlength="1" required/>
	                	</div>
                	</div>
                	<div class="form-group">
	                	<label class="col-sm-3 control-label">车主电话</label>
	                	<div class="col-sm-9">
	                		<input id="ownerPhone" class="form-control" name="ownerPhone" v-model="item.ownerPhone" minlength="1" required/>
	                	</div>
                	</div>
                	
                	<!-- <div class="form-group">
	                	<label class="col-sm-3 control-label">录入时间</label>
	                	<div class="col-sm-9">
	                		<input id="enterTime" class="form-control" name="enterTime" v-model="item.enterTime" minlength="" required/>
	                	</div>
                	</div>  -->
                	<div class="form-group">
	                	<label class="col-sm-3 control-label">是否可用</label>
	                	<div class="col-sm-9">
	                		<select id="useable" class="form-control" name="useable" v-model="item.useable" minlength="1" required>
	                		@for(opt in constant.getDictMap("sys_yes_no")){
								<option value="${opt.key}" >${opt.value}</option>
							@}
							</select>
	                	</div>
                	</div> 
                	<div class="form-group">
	                	<label class="col-sm-3 control-label">车辆类型</label>
	                	<div class="col-sm-9">
	                		<select id="carType" class="form-control" name="carType" v-model="item.carType" minlength="1" required>
	                		@for(opt in constant.getDictMap("platform_carType")){
								<option value="${opt.key}" >${opt.value}</option>
							@}
	                		</select>
	                	</div>
                	</div> 
                	
                	
                </div>

                <div class="col-sm-6">
                
                	<div class="form-group">
	                	<label class="col-sm-3 control-label">车长</label>
	                	<div class="col-sm-6">
	                		<input id="length" class="form-control" name="length" v-model="item.length" minlength="1" required/>
	                	</div>
                	</div> 
                	<div class="form-group">
	                	<label class="col-sm-3 control-label">车宽</label>
	                	<div class="col-sm-6">
	                		<input id="wide" class="form-control" name="wide" v-model="item.wide" minlength="1" required/>
	                	</div>
                	</div> 
	                <div class="form-group">
	                	<label class="col-sm-3 control-label">车高</label>
	                	<div class="col-sm-6">
	                		<input id="high" class="form-control" name="high" v-model="item.high" minlength="1" required/>
	                	</div>
                	</div> 
                	<div class="form-group">
	                	<label class="col-sm-3 control-label">限载（吨）</label>
	                	<div class="col-sm-6">
	                		<input id="limitWeigh" class="form-control" name="limitWeigh" v-model="item.limitWeigh" minlength="1" required/>
	                	</div>
                	</div> 
                	
                </div>
            </div>
			
            <div class="hr-line-dashed"></div>
			
            <div class="row btn-group-m-t">
                <div class="col-sm-10">
                    <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="submitForm();"/>
                    <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="parent.layer.close(parent.layer.getFrameIndex(window.name));"/>
                </div>
            </div>
        </div>

    </div>
</div>
<script>
function submitForm(){
	$("#data-input").bootstrapValidator('validate');
	if($("#data-input").data('bootstrapValidator').isValid()){
		$.ajax({
			url:"/ptcar/save",
			data:{"object":JSON.stringify(mv.item)},
			type:"POST",
			success:function(){
				if(mv.item.id!=""&&mv.item.id!=undefined&&mv.item.id!=null){
					parent.mv.$set(parent.mv.tableData,parent.carselectIndex,mv.item);
				}else{
					parent.mv.loadData();
				}
				parent.layer.msg("操作成功！");
				parent.layer.close(parent.layer.getFrameIndex(window.name));
				
			},
			error:function(){
				layer.msg("出错了！");
			}
		})
	}
}

var mv=new Vue({
	el:"#data-input",
	data () {
		return {
			item: {useable:"1",carType:"1"},
		}
	},
})
@if(has(id)){
	$.ajax({
		url:"/ptcar/"+'${id}',
		type:"GET",
		success:function(result){
			mv.item=result;
		},
		error:function(){
			layer.msg("出错了！");
		}
	})
@}
</script>
@}
